In this demonstration, you explore relationships between numeric predictors and the response variable Donation_Amt using correlation analysis in a SAS Studio flow. Then the input GiftAvgCard36, which is most correlated with the target, is used in a simple linear regression.
Reminder: If you restarted your SAS session, or it has timed out due to inactivity, you must re-create the course libraries, LOCALLIB and VST. To do this, run the AssignLibrary flow.
Demo Steps
Correlation analysis
Note: If you see a warning message in the results window that says The maximum size limit has been exceeded, you might want to click the Open in new tab link to view the results. Alternatively, go to the SAS Studio Options menu, and select Preferences. Under SAS Programs, click Results. Under Display warning if results are larger than specific size, change the Maximum result size (MB) from 3 to 10.
Each cell in the Correlation table lists several pieces of information: the variable correlated with the response Donation_Amt, the estimate of the correlation coefficient, the p-value, and the sample size. The p-value is for a test of the null hypothesis that the population correlation equals zero. The sample size depends on the number of nonmissing values for only the two variables being correlated. Because of this, the sample size can differ for each correlation.
The correlations have been ranked from strongest to weakest. The strongest correlation with the target is approximately 0.65 for GiftAvgCard36. This positive correlation indicates that as GiftAvgCard36 increases, Donation_Amt tends to increase. It will likely be a good predictor in a regression model for Donation_Amt. The weakest correlation with the target is -0.006 for PromCntCard12. This negative correlation is not statistically different from zero at any commonly used alpha level.
Correlations measure the linear associations between variables. Scatter plots can be useful for assessing linear relationships and thus the appropriateness of correlation analysis. For large data sets, scatter plots can be challenging to interpret when many dots fall on top of each other and are indistinguishable. Prediction ellipses can help you visualize the strength and direction of a correlation. The plots show 95% prediction ellipses for 5 of the 20 variable pairs. The 95% prediction ellipses show where 95% of the data points are expected to lie if both variables are normally distributed. The sign of the correlation becomes obvious from the orientation of the ellipse. The narrower the ellipse, the stronger the linear association between the variables. None of the five plots show strong nonlinear relationships, indicating that correlation is a reasonable tool for describing relationships between these variables. Some plots show unusual data points such as the plot showing Gift Amount Last. Unusual data points, often called outliers, are discussed in a later lesson.
Simple linear regression
Next, we will use a regression node in a flow to regress Donation_Amt onto GiftAvgCard36, the most correlated variable identified earlier in this demonstration. This will produce parameter estimates and hypothesis tests that can be used to understand relationship between variables, as well as a regression equation that can be used to predict future donations from lapsing donors.
In the simple linear regression model, Donation_Amt is regressed on GiftAvgCard36. Only 4111 observations are used. We learned in an earlier lesson that Donation_Amt has missing values for approximately half the observations. Any observation with missing values for the predictor or response is dropped from the analysis.
The Analysis of Variance table shows that the model is significant with P < 0.0001. The R-square indicates that about 42% of the variability in Donation_Amt can be explained by GiftAvgCard36. The adjusted R-square equals 0.42, and the mean square error (MSE) is approximately 392. MSE, also called the error variance, is a measure of the variance in the response variable that is not explained by this model. Both the adjusted R-square and MSE can be used for model comparisons, with higher adjusted R-square or lower MSE indicating a better model.
The Parameter Estimates table shows that the estimated intercept equals 75.41694 and the estimated slope for GiftAvgCard36 equals 1.79672. Thus, the regression model for estimated donation amount is
The p-value for the GiftAvgCard36 parameter indicates that the population slope is significantly different from zero. Thus, this predictor can be useful to predict future donation amounts. The slope of 1.80 indicates that for every additional dollar of GiftAvgCard36, the predicted donation amount will increase by $1.80. The 95% confidence interval on the slope for GiftAvgCard36 indicates the parameter estimate is likely between (1.73, 1.86). The intercept is also significantly different than zero, but tests of the intercept are often less relevant than tests of the slope. In this case, the intercept tells us that the average donation equals $75.42 when GiftAvgCard36 equals zero.
The plot of Observed by Predicted values of Donation_Amt shows that predictions match observed donations poorly when observed donations are under $100.
Several diagnostic plots based on residuals (the difference between observed and predicted values of the response) are shown. These can be used to assess whether the model assumptions are met and to detect extreme observations. Both of these topics are discussed later in this lesson.
The Fit plot shows Donation_Amt plotted against GiftAvgCard36. The best-fit regression line (the solid black line) indicates the predicted value of Donation_Amt for specific values of GiftAvgCard36. The thin light gray shaded region around the regression line indicates the 95% confidence interval on the mean response for specific values of the predictor. It is difficult to see here in the picture Fit Plot, but the confidence intervals are narrowest near the mean values of X and Y and widest at the extremes. The dashed lines show the 95% prediction limits. You can be 95% confident that new observations will lie within these prediction limits.